From: Sebastian Wick Date: Mon, 20 Oct 2025 11:38:37 +0000 (+0200) Subject: brightnessManager: Use slider as bias when auto brightness is being used X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~44^2~146 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=157f6124d894143c7ce82559d4b845af07462928;p=gnome-shell.git brightnessManager: Use slider as bias when auto brightness is being used The code previously tried to ensure that the sliders were disabled when auto brightness was active, and determine the brightness just from the auto brightness target we get from g-s-d. It turns out that users do want to still have some control over the brightness, even if auto brightness is active. The slider is now being used as a bias for the auto brightness target instead. This also means that we can drop the BrightnessScale::locked property. Part-of: --- diff --git a/js/misc/brightnessManager.js b/js/misc/brightnessManager.js index eb4ad1b46..8ac347785 100644 --- a/js/misc/brightnessManager.js +++ b/js/misc/brightnessManager.js @@ -236,14 +236,20 @@ export const BrightnessManager = GObject.registerClass({ this._showOSD(this._monitorScales.values()); } - // ensure we lock the global scale when auto brightness is in control - this._globalScale.locked = this._abTarget >= 0.0; - // Update the actual backlight according to the new monitor brightnesses // and other factors, such as dimming. for (const scale of this._monitorScales.values()) { + // If auto brightness is active (_abTarget >= 0) we use the scale + // as a bias for the auto brightness target to determine the target + // brightness. + // Otherwise the target brightness just comes from the scale. + const target = this._abTarget >= 0.0 + ? Math.clamp(this._abTarget + scale.value - 0.5, 0.0, 1.0) + : scale.value; + + // the actual brightness is then determined by clipping to the + // dimming target, if dimming is enabled const max = this._dimmingEnabled ? this._dimmingTarget : 1.0; - const target = this._abTarget >= 0.0 ? this._abTarget : scale.value; const brightness = Math.min(max, target); scale.setBacklight(brightness); @@ -273,10 +279,6 @@ export const BrightnessScale = GObject.registerClass({ 'value', null, null, GObject.ParamFlags.READWRITE, 0, 1.0, 1.0), - 'locked': GObject.ParamSpec.boolean( - 'locked', null, null, - GObject.ParamFlags.READWRITE, - false), }, }, class BrightnessScale extends GObject.Object { constructor(name, value = 1.0, nSteps = SCALE_VALUE_N_STEPS) { @@ -284,7 +286,6 @@ export const BrightnessScale = GObject.registerClass({ this._name = name; this._value = value; - this._locked = false; this._nSteps = nSteps; } @@ -300,17 +301,6 @@ export const BrightnessScale = GObject.registerClass({ this._setValue(value); } - get locked() { - return this._locked; - } - - set locked(locked) { - if (this._locked === locked) - return; - this._locked = locked; - this.notify('locked'); - } - get nSteps() { return this._nSteps; } diff --git a/js/ui/status/brightness.js b/js/ui/status/brightness.js index 2ca09f342..bee51155a 100644 --- a/js/ui/status/brightness.js +++ b/js/ui/status/brightness.js @@ -50,13 +50,6 @@ class BrightnessItem extends QuickSlider { this._manager = Main.brightnessManager; this._manager.connectObject('changed', - this._onManagerChanged.bind(this), this); - this._onManagerChanged(); - } - - _onManagerChanged() { - this._manager.globalScale?.disconnectObject(this); - this._manager.globalScale?.connectObject('notify::locked', this._sync.bind(this), this); this._sync(); } @@ -64,7 +57,7 @@ class BrightnessItem extends QuickSlider { _sync() { const {globalScale} = this._manager; this.set({ - visible: globalScale && !globalScale.locked, + visible: globalScale, menuEnabled: this._manager.scales.length > 1, });